<!DOCTYPE html>
<html 
<head >
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css"  media="all"/>
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all"/>
<link rel="stylesheet"  href="../../../css/common/loader.css" media="all"/>
<link rel="stylesheet"  href="../../../css/common/tablepage.css" media="all"/>
</head>
<style>
	.sort-box{margin:0 5px;}
	.sort-box:hover{cursor: pointer;}
</style>
<body>
	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-form layui-card-header layuiadmin-card-header-auto" id="searchForm">
			   <div class="layui-form-item">

                 <div class="layui-inline">
				  <label class="layui-form-label">卓番</label>
				  <div class="layui-input-block">
				  <input type="text" name="deskName"  autocomplete="off" class="layui-input">
				   </div>
				 </div>
                 <div class="layui-inline">
				  <label class="layui-form-label">エリア</label>
				  <div class="layui-input-block">
				  <select name="areaId"  id="areaId"></select>
				   </div>
				 </div>
                <div class="layui-inline">
				<label class="layui-form-label">状態</label>
				<div class="layui-input-block">
				<select name="deskStatus" lay-select-dict="desk_status" >
								
				</select>
				</div>		
				</div>

                
				 <div class="layui-inline">
				  <button class="layui-btn layuiadmin-btn-sm" lay-submit
							lay-filter="searchSubmit"  >検索</button>
				</div>
				</div>
			</div>
			<div class="layui-card-body">
				<table id="dataList" lay-filter="dataList" ></table>
				
	
			</div>
		</div>
	</div>
<script type="text/html" id="barDemo">
  <a class="sort-box" lay-event="upt" title="置顶"><img src="../../../img/arrow-upt.png" ></a>
  <a class="sort-box" lay-event="up"  title="上移一位"><img src="../../../img/arrow-up.png"></a>
  <a class="sort-box" lay-event="down"  title="下移一位"><img src="../../../img/arrow-down.png"></a>
  <a class="sort-box" lay-event="downt"  title="置底"><img src="../../../img/arrow-downt.png"></a>
</script>
<div type="text/html" id="trTool" style="display:none">
    <a  data-grant="buss:desk:edit" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>編集</a>
    {{#  if(d.orderNo){ }}
     <a data-grant="buss:desk:qrcode" class="layui-btn layui-btn-success layui-btn-xs" lay-event="qrcode"><i class="layui-icon layui-icon-share"></i>QR</a>
     
     {{#  } else { }}
     <a data-grant="buss:desk:order" class="layui-btn layui-btn-warm layui-btn-xs" lay-event="order"><i class="layui-icon layui-icon-face-smile-fine"></i>オーダー</a>

      {{#  } }}
    <a  data-grant="buss:desk:remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>削除</a>
</div>

<div type="text/html" id="toolbar" style="display:none" >
<div class="layui-btn-container">
     <button data-grant="buss:desk:add"   class="layui-btn layui-btn-sm" lay-event="add"> <i class="layui-icon layui-icon-add-1"></i>追加</button>
</div>
</div>
<script type="text/html" id="showPriceTpl">
  <input type="checkbox" name="whetherShowPrice" value="{{d.deskId}}"  lay-skin="switch" lay-text="表示|非表示" lay-filter="whetherShowPrice" {{ d.whetherShowPrice == '1' ? 'checked' : '' }}>
</script>
<script   src="../../../layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="../../../lib/jQuery-2.2.0.min.js" ></script>
	<script>
		layui.config({
			base :  '../../../layuiadmin/' //静态资源所在路径
		}).extend({
			webplus : 'lib/webplus'//主入口模块
			
		}).use([ 'table','form','webplus' ], function() {
			var $ = layui.$,
			webplus=layui.webplus,
			form = layui.form,
			table = layui.table;
			 webplus.createCustomSelect('areaId','buss/area/queryAreaList',{},'areaId','areaName','','選択')
		   var cols= [ [ {
				type : 'numbers',
				title : '番号'
			}, {
				field : 'deskId',
				title : '编号',
				hide : true 
			},
            {
			 field : 'deskName',
			 title : '卓番',
			 width:110
			},
			{
				 field : 'areaName',
				 title : 'エリア',
				 width:150
			},
            
            {
			 field : 'deskStatus_dict',
			 title : '状態',
			 width:120
			},
			{
				field : 'whetherShowPrice',
				title : '価格表示',
				templet: '#showPriceTpl', 
				unresize: true,
				width : 110
			},
	            
			{
				 field : 'displayType_dict',
				 title : 'メニュー切替',
				 width:120
				},
	            
            {title: '並び替え', width:150, toolbar: '#barDemo'},
			{

				title : '編集',
				toolbar : '#trTool',
				fixed: 'right',
				minWidth :240
			} ] ];
		   webplus.init('buss/desk/list',cols)
			 //监听行工具事件
			  table.on('tool(dataList)', function(rowObj){
				var id=rowObj.data.deskId;
				var params = {};
				params.id=id;
			    switch(rowObj.event){
			    	case 'edit':
			    		webplus.openEditWindow('editDesk.html','編集',rowObj,'deskId','','500','450');
			    	case 'order':
			    		webplus.openEditWindow('addOrderNum.html','オーダー',rowObj,'deskId','','500','200');
			       		
			   			break;
			    	case 'qrcode':
			    		webplus.openDetailWindow('showOrderQrcode.html','QR',rowObj,'deskId','','600','440');
			       		
			   			break;
			    	case 'del':
				    	
				        webplus.removeRow('buss/desk/remove',rowObj,'deskId','','','卓番を削除しますか？');
			    		break;
					case 'upt':
						params.sortWay="1";
						webplus.doAjax("buss/desk/updateSort",params,"","","0");
						break;
					case 'up':
						params.sortWay="2";
						webplus.doAjax("buss/desk/updateSort",params,"","","0");
						
						break;
					case 'down':
						params.sortWay="3";
						webplus.doAjax("buss/desk/updateSort",params,"","","0");
						
						break;
					case 'downt':
						params.sortWay="4";
						webplus.doAjax("buss/desk/updateSort",params,"","","0");
						
						break;
			    }
			  });
			 //监听表头按钮事件
			  table.on('toolbar(dataList)', function(obj){
			    switch(obj.event){
			      	case 'add':
				         //打开添加弹出框
				         webplus.openWindow('addDesk.html','追加','500','400');
			     	     break;
			    }
			  });
			  //监听启用操作
			  form.on('switch(whetherShowPrice)', function(obj){
				  if(webplus.checkFormEditMode(obj)){
					  var whetherShowPrice="0";
			    	   if(obj.elem.checked){
			    		   whetherShowPrice="1";
			    	   }
			    	   
			    	   var params={};
			    	   params.deskId=obj.value;
			    	   params.whetherShowPrice=whetherShowPrice;
			    	   webplus.doAjax("buss/desk/updateDeskPriceStatus",params,"","","3")
				  }
					 
			  });
		});
	</script>

</body>
</html>